package cn.wolfcode.mp.domain;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.HashMap;

@Setter
@Getter
@ToString
@TableName("t_department")
public class Department {

    @TableId(value="id", type= IdType.AUTO)
    private Long id;
    private String name;
    private String sn;

    public String toJson(){
        HashMap<String, Object> map = new HashMap<>(); // 更安全
        map.put("id",id);
        map.put("name",name);
        map.put("sn",sn);
        //转为标准的json格式字符串
        return JSON.toJSONString(map);
    }
}
